package com.mavenq.fly.utils.excelv4.example;



import java.math.BigDecimal;
import java.util.*;

/**
 * 测试数据生成器
 */
public class TestDataGenerator {
    
    /**
     * 生成测试用户数据
     */
    public static List<User> generateTestUsers(int count) {
        List<User> users = new ArrayList<>();
        Random random = new Random();
        String[] departments = {"技术部", "销售部", "市场部", "人事部", "财务部"};
        
        for (int i = 1; i <= count; i++) {
            User user = new User(
                (long) i,
                "用户" + i,
                20 + random.nextInt(40),
                "user" + i + "@example.com",
                new BigDecimal(5000 + random.nextInt(20000)),
                new Date(System.currentTimeMillis() - random.nextInt(365 * 24 * 60 * 60 * 1000)),
                random.nextBoolean(),
                departments[random.nextInt(departments.length)]
            );
            users.add(user);
        }
        return users;
    }
    
    /**
     * 生成测试产品数据
     */
    public static List<Product> generateTestProducts(int count) {
        List<Product> products = new ArrayList<>();
        Random random = new Random();
        String[] categories = {"电子产品", "服装", "食品", "家居", "图书"};
        
        for (int i = 1; i <= count; i++) {
            Product product = new Product(
                "P" + String.format("%05d", i),
                "产品" + i,
                10.0 + random.nextDouble() * 990,
                50 + random.nextInt(950),
                categories[random.nextInt(categories.length)]
            );
            products.add(product);
        }
        return products;
    }
    
    /**
     * 生成包含错误数据的用户列表（用于测试校验）
     */
    public static List<User> generateUsersWithErrors(int count) {
        List<User> users = generateTestUsers(count);
        
        // 添加一些错误数据
        if (count >= 3) {
            // 第1个用户：年龄过大
            users.get(0).setAge(200);
            // 第2个用户：邮箱格式错误
            users.get(1).setEmail("invalid-email");
            // 第3个用户：姓名为空
            users.get(2).setName("");
        }
        
        return users;
    }
}